<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:loodel="http://java.sun.com/jsf/composite/component"
        >
<ui:composition template="/WEB-INF/template/mainTemplate.xhtml">
    <ui:param name="activePage" value="edit"/>
    <ui:define name="metadata">
        <f:metadata>
            <f:viewParam name="id" value="#{learningEventAdminModel.learningEventId}"/>
            <f:event type="preRenderView" listener="#{learningEventAdminController.init}"/>
        </f:metadata>
    </ui:define>
    <ui:define name="content">
        <div>
            <h1>Edit Learning Event</h1>
            <h:form id="voteForm" class="form-inline">
                <p:messages errorClass="error" autoUpdate="true"/>
                <p:panel id="invalidId" rendered="#{empty learningEventAdminModel.learningEventId}">
                    <h:inputText id="learningEventIdInput" value="#{learningEventAdminModel.learningEventId}"
                                 placeholder="Enter Learning Event ID" autofocus="true" required="true"
                                 label="Learning Event ID"/>
                    <p:commandButton action="#{learningEventAdminController.enterLearningEventIdAction}" value="Edit"
                                     update="@form" process="@form"/>
                </p:panel>
                <p:panel id="validId" rendered="#{!empty learningEventAdminModel.learningEventId}">
                    <loodel:learningEventSummary id="eventSummary"
                                                 learningEventVoteData="#{learningEventAdminModel.learningEventVoteData}"/>
                    <p:tabView id="tabView">
                        <p:tab title="Accept Learning Events">
                            <p:accordionPanel value="#{learningEventAdminModel.allMembersTimeSlotVotesDatas}"
                                              var="timeSlot">
                                <p:tab title="#{timeSlot.timeSlotData.longTitle} #{timeSlot.timeSlotData.shortStartDateTime}"
                                       titleStyleClass="#{learningEventAdminModel.acceptedTimeSlots[timeSlot] ? 'voted-event' : 'unvoted-event'}">
                                    <p:dataList value="#{timeSlot.memberTimeSlotVotes}" var="timeSlotVote"
                                                itemType="disc">
                                        #{timeSlotVote.voter.fullName}  #{timeSlotVote.voteTime}
                                    </p:dataList>
                                    <p:commandButton value="Accept this TimeSlot" update="@form"
                                                     rendered="#{!learningEventAdminModel.acceptedTimeSlots[timeSlot]}"
                                                     action="#{learningEventAdminController.acceptTimeSlotAction}">
                                        <f:setPropertyActionListener value="#{timeSlot}"
                                                                     target="#{learningEventAdminModel.selectedTimeSlotData}"/>
                                    </p:commandButton>
                                    <p:commandButton value="Reject  this TimeSlot" update="@form"
                                                     rendered="#{learningEventAdminModel.acceptedTimeSlots[timeSlot]}"
                                                     action="#{learningEventAdminController.rejectTimeSlotAction}">
                                        <f:setPropertyActionListener value="#{timeSlot}"
                                                                     target="#{learningEventAdminModel.selectedTimeSlotData}"/>
                                    </p:commandButton>
                                </p:tab>
                            </p:accordionPanel>
                            <p:commandButton value="Apply selected time slots"
                                             action="#{learningEventAdminController.closeLearningEvent}"
                                             update="@form"/>

                        </p:tab>
                    </p:tabView>
                </p:panel>


            </h:form>
        </div>

        <div class="clear"></div>
    </ui:define>
</ui:composition>
</html>
